package cn.sumpu.app.guoguojie.constant;

import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Map.Entry;

public enum Expression {
	ANGRY("angry.gif", "/生气"), AWKWARD("awkward.gif", "/尴尬"),BYE("bye.gif", "/再见"),CRAZY("crazy.gif", "/疯狂"),
	CRY("cry.gif", "/哭泣"), CURSE("curse.gif", "/诅咒"),CUTE("cute.gif", "/可爱"),DISPISE("despise.gif", "/蔑视"),
	DOUBT("doubt.gif", "/疑惑"), ENVY("envy.gif", "/羡慕"),FASTCRY("fastcry.gif", "/难过"),KNOCK("knock.gif", "/批评"),
	LAUGH("laugh.gif", "/嘲笑"), MAD("mad.gif", "/发疯"),OHMY("ohmy.gif", "/郁闷"),PANIC("panic.gif", "/恐慌"),
	PROUD("proud.gif", "/自豪"), QUIET("quiet.gif", "/安静"),SAD("sad.gif", "/伤心"),SHUTUP("shutup.gif", "/闭嘴"),
	SHY("shy.gif", "/害羞"), SLEEP("sleep.gif", "/睡觉"),SMILE("smile.gif", "/微笑"),STRUGGLE("struggle.gif", "/小样"),
	TITTER("titter.gif", "/傻笑"), TONGUE("tongue.gif", "/撒娇"),WAIL("wail.gif", "/痛哭"),WRONGED("wronged.gif", "/委屈");

	private String value;
	private String label;

	private Expression(String value, String label) {
		this.value = value;
		this.label = label;
	}
	
	public static Map<String,String> cache;
	
	static {
		cache = new HashMap<String,String>();
		//第一行
		cache.put(ANGRY.getValue(), ANGRY.getLabel());
		cache.put(AWKWARD.getValue(), AWKWARD.getLabel());
		cache.put(BYE.getValue(), BYE.getLabel());
		cache.put(CRAZY.getValue(), CRAZY.getLabel());
		
		//第二行
		cache.put(CRY.getValue(), CRY.getLabel());
		cache.put(CURSE.getValue(), CURSE.getLabel());
		cache.put(CUTE.getValue(), CUTE.getLabel());
		cache.put(DISPISE.getValue(), DISPISE.getLabel());
		
		//第三行
		cache.put(DOUBT.getValue(), DOUBT.getLabel());
		cache.put(ENVY.getValue(), ENVY.getLabel());
		cache.put(FASTCRY.getValue(), FASTCRY.getLabel());
		cache.put(KNOCK.getValue(), KNOCK.getLabel());
		
		//第四行
		cache.put(LAUGH.getValue(), LAUGH.getLabel());
		cache.put(MAD.getValue(), MAD.getLabel());
		cache.put(OHMY.getValue(), OHMY.getLabel());
		cache.put(PANIC.getValue(), PANIC.getLabel());
		
		//第五行
		cache.put(PROUD.getValue(), PROUD.getLabel());
		cache.put(QUIET.getValue(), QUIET.getLabel());
		cache.put(SAD.getValue(), SAD.getLabel());
		cache.put(SHUTUP.getValue(), SHUTUP.getLabel());
		
		//第六行
		cache.put(SHY.getValue(), SHY.getLabel());
		cache.put(SLEEP.getValue(), SLEEP.getLabel());
		cache.put(SMILE.getValue(), SMILE.getLabel());
		cache.put(STRUGGLE.getValue(), STRUGGLE.getLabel());
		
		//第七行
		cache.put(TITTER.getValue(), TITTER.getLabel());
		cache.put(TONGUE.getValue(), TONGUE.getLabel());
		cache.put(WAIL.getValue(), WAIL.getLabel());
		cache.put(WRONGED.getValue(), WRONGED.getLabel());
	}
	
	public String getValue() {
		return value;
	}

	public String getLabel() {
		return label;
	}
	
	public static String getLabelByValue(String value) {
		return cache.get(value);
	}
	
	//替换表情字符
	public static String replaceAll(String content){
		if(content == null)
			return "";
		content = content.replace("<", "&lt;");
		Iterator<Entry<String, String>> it = cache.entrySet().iterator();
		while (it.hasNext()) {
		    Entry<String, String> entry = it.next();
		    String key = entry.getKey();
		    String value = entry.getValue();
		    content = content.replace((CharSequence) value, "<img src='images/expression/"+key+"' />");
		}
		return content;
	}
	
}
